#pragma once

#include"HiKernel/HiModule.h"
#include "HiModules/mHiLFSM/Miner.h"
#include "luahelperfunctions.h""


//include the libraries
#pragma comment(lib, "lua.x86.debug.lib")
#pragma comment(lib, "luabind.x86.debug.lib")
#pragma warning (disable : 4786)

extern "C"
{
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
}

#include <luabind/luabind.hpp>
using namespace luabind;


class HI_DLLEXPORT mHiLFSM : public HiModule
{
protected:
	Miner* m_pminer;
	lua_State* m_pLua;
	object m_states;
	//LuaExceptionGuard m_guard;


public:
	mHiLFSM(HiXmlNode*xml=NULL) {}                                   
	~mHiLFSM();          

	void PostConfig();                  
	void Update();
	bool HandleMessage(const Telegram& msg);


	void RegisterScriptedStateMachineWithLua(lua_State* pLua);
	void RegisterEntityWithLua(lua_State* pLua);
	void RegisterMinerWithLua(lua_State* pLua);


	virtual int ParseXml(HiXmlNode*xml) {return 1;};
	virtual int SetXmlAttrs(HiXmlNode*xml)                  { return 1; }

};